﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Chapter33
{
    public class MainWindowViewModel
    {
        private List<Unit> catalogues = new List<Unit>();

        public List<Unit> Catalogues
        {
            get { return catalogues; }
        }

        public MainWindowViewModel()
        {
            catalogues.Add(new Unit { Num = 1, Title = "用 Entity Framework 编程" });
            catalogues.Add(new Unit
            {
                Num = 2,
                Title = "Entiry Framework 映射",
                ChildCatalogues = new List<Unit> 
                { 
                    new Unit { Num = 2.1, Title = "逻辑层" }, 
                    new Unit { Num = 2.2, Title = "概念层" }, 
                    new Unit { Num = 2.3, Title = "映射层" } 
                }
            });
            catalogues.Add(new Unit { Num = 3, Title = "实体" });
            catalogues.Add(new Unit { Num = 4, Title = "对象上下文" });
            catalogues.Add(new Unit
            {
                Num = 5,
                Title = "关系",
                ChildCatalogues = new List<Unit> 
                {
                    new Unit { Num = 5.1, Title = "一个层次结构一个表" }, 
                    new Unit { Num = 5.2, Title = "一种类型一个表" }, 
                    new Unit { Num = 5.3, Title = "懒惰加载、延迟加载和预先加载" }   
                }
            });
            catalogues.Add(new Unit
            {
                Num = 6,
                Title = "查询数据",
                ChildCatalogues = new List<Unit>
                {
                    new Unit { Num = 6.1, Title = "Entity SQL" }, 
                    new Unit { Num = 6.2, Title = "对象查询" }, 
                    new Unit { Num = 6.3, Title = "LINQ to Entities" }   
                },
            });
            catalogues.Add(new Unit
            {
                Num = 7,
                Title = "把数据写入数据库",
                ChildCatalogues = new List<Unit> 
                {
                    new Unit { Num = 7.1, Title = "对象跟踪" }, 
                    new Unit { Num = 7.2, Title = "对象查询" }, 
                    new Unit { Num = 7.3, Title = "LINQ to Entities" }   
                }
            });
            catalogues.Add(new Unit
            {
                Num = 8,
                Title = "使用 POCO 对象",
                ChildCatalogues = new List<Unit> 
                { 
                    new Unit { Num = 8.1, Title = "定义实体类型" }, 
                    new Unit { Num = 8.2, Title = "创建数据上下文" }, 
                    new Unit { Num = 8.3, Title = "查询和更新" }, 
                }
            });
            catalogues.Add(new Unit { Num = 9, Title = "使用 Code First 编程模型" });
            catalogues.Add(new Unit { Num = 10, Title = "小结" });
        }

        public class Unit
        {
            public double Num { get; set; }
            public string Title { get; set; }
            public string Sample { get; set; }
            public List<Unit> ChildCatalogues { get; set; }
        }

        public override string ToString()
        {
            return "第33章 ADO.NET Entity Framework";
        }
    }
}
